function content0LoadFunction() {
	// Load up the calendar
	var dateEnd = new Ext.form.DateField({
	    name: 'lDateEnd',
	    width:150,
	    allowBlank:false,
	    format: 'm/d/Y'
	});
	dateEnd.applyTo('lDateEnd');
	
	// Reset action hidden field to 'add'
	$('action').value = 'add';
	
	// Get existing employment entries
	x_getJobs(returnGetJobs);
}

function content1LoadFunction() {
		
}

function returnGetJobs(string) {
	$('currentJobs').innerHTML = string;
}

function addListing() {
	// Turn off add button
	$('buttonNewListing').style.display = 'none';
	
	// Set formAction to 'add'
	$('action').value = 'add';
	
	// Clear form
	clearForm();
	
	// Display add form
	new Effect.SlideDown('formNewListing', {direction: 'top', duration: .3});
}

function clearForm() {
	$('lTitleBox').value = '';	
	tinyMCE.getInstanceById('lDesc').getBody().innerHTML = '';	
	$('lDateEnd').value = '';	
}

function cancelListing() {
	// Remove add form
	new Effect.SlideUp('formNewListing', {direction: 'top', duration: .3});
	// Turn on Add New button
	$('buttonNewListing').style.display = 'block';
	
	clearForm();
}

function saveListing() {
	var lID = $('lID').value;
	var action   = $('action').value;
	var lTitle   = $('lTitleBox').value;
	var lDesc    = tinyMCE.getContent('lDesc');
	var lDateEnd = $('lDateEnd').value;	
	
	var phpString  = lTitle+'|'+lDesc+'|'+lDateEnd;
	x_saveListing(phpString,action,lID,returnSaveListing);
}

function returnSaveListing() {
	// Are we adding or editing
	var action = $('action').value;
	
	// Close add product form
	cancelListing();
	if (action == 'add') {
		var message = 'New employment listing has been successfully added.';
	} else {
		var message = 'Employment listing has been updated.';
	}	
	updateStatus(message,'success','statusDiv');	
	x_getJobs(returnGetJobs);
}

function returnDeleteListing() {
	var message = 'Emplyment listing has been deleted.';
	updateStatus(message,'success','statusDiv');
	x_getJobs(returnGetJobs);
}

function editListing(lID) {
	x_getListingForEdit(lID,returnGetListingForEdit);
}

function returnGetListingForEdit(string) {
	// Parse string
	stringArray = string.split("|");
	var lID      = stringArray[0];
	var lTitle   = stringArray[1];
	var lDesc    = stringArray[2];
	var lDateEnd = stringArray[3];	
	
	$('lTitleBox').value = lTitle;
	tinyMCE.getInstanceById('lDesc').getBody().innerHTML = lDesc;	
	$('lDateEnd').value = lDateEnd;
	
	// Set formAction to 'edit'
	$('action').value = 'edit';
	
	// Set lID
	$('lID').value = lID;
		
	// Turn off add button
	$('buttonNewListing').style.display = 'none';
	
	// Scroll to top of panel
	//content0.getEl().scrollTo('top',10);
	Ext.get('content0').scrollTo('top',10);
	//Ext.get('formNewListing').scrollIntoView(panel0.getEl());
	
	// Display add form
	new Effect.SlideDown('formNewListing', {direction: 'top', duration: .3});
	
}


